package com.cheyunkeji.er.activity;

import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.cheyun.netsalev3.R;
import com.cheyunkeji.er.adapter.HcPageAdapter;
import com.cheyunkeji.er.base.BaseActivity;

import java.util.ArrayList;
import java.util.List;

import androidx.viewpager.widget.ViewPager;
import butterknife.BindView;
import butterknife.ButterKnife;

public class GuideActivity extends BaseActivity {



    @BindView(R.id.vp_guide)
    ViewPager vpGuide;
    @BindView(R.id.activity_guide)
    RelativeLayout activityGuide;

    private HcPageAdapter hcPageAdapter;
    private List<View> ivList;

    @Override
    protected void init() {
        setContentView(R.layout.activity_guide);
        ButterKnife.bind(this);
    }

    @Override
    protected void initView() {

        ivList = new ArrayList<>();

        View v0 = getLayoutInflater().inflate(R.layout.er_v_guide, null);
        ImageView iv0 = (ImageView) v0.findViewById(R.id.vImg);
        iv0.setImageResource(R.mipmap.er_guide_01);

        View v1 = getLayoutInflater().inflate(R.layout.er_v_guide, null);
        ImageView iv1 = (ImageView) v1.findViewById(R.id.vImg);
        iv1.setImageResource(R.mipmap.er_guide_02);

        View v2 = getLayoutInflater().inflate(R.layout.er_v_guide, null);
        ImageView iv2 = (ImageView) v2.findViewById(R.id.vImg);
        iv2.setImageResource(R.mipmap.er_guide_03);

        View v3 = getLayoutInflater().inflate(R.layout.er_v_guide, null);
        ImageView iv3 = (ImageView) v3.findViewById(R.id.vImg);
        TextView tiyanText = (TextView) v3.findViewById(R.id.tiyan_text);
        tiyanText.setVisibility(View.VISIBLE);
        iv3.setImageResource(R.mipmap.er_guide_04);
        tiyanText.setOnClickListener(this);

        ivList.add(v0);
        ivList.add(v1);
        ivList.add(v2);
        ivList.add(v3);

        hcPageAdapter = new HcPageAdapter(ivList);
        vpGuide.setAdapter(hcPageAdapter);

//        if(!MyApplication.getInstance().hasCheckVersion) {
//            new Handler().postDelayed(new Runnable() {
//                @Override
//                public void run() {
//                    UpdatePresenter presenter = new UpdatePresenter(GuideActivity.this, 3);
//                    presenter.getVersionInfo();
//                    MyApplication.getInstance().hasCheckVersion = true;
//                }
//            }, 2000);
//        }
    }

    @Override
    protected void initData() {

    }

    @Override
    public void onClick(View v) {

        if (v.getId() == R.id.tiyan_text) {
            startActivity(new Intent(GuideActivity.this, LoginActivity.class));
            finish();
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

        vpGuide.removeAllViews();
        ivList.clear();
        ivList = null;
    }


}
